#include<bits/stdc++.h>
using namespace std;
int main(){
	freopen("floor.in" , "r" , stdin);
	freopen("floor.out" , "w" , stdout);
	long long m , t;
	cin >> m >> t;
	long long k = m;
	for(long long i = 1 ; i <= k ; i++){
		long long a , b = i;
		int flag = 0;
		while(b > 0){
			a = b % 10;
			if(flag == 0 && a == t){
				flag = 1;
				m--;
			}
			b = b / 10;
		}
	}
	cout << m << endl;
	return 0;
} 
